#ifndef ROTARY_ENCODER_H
#define ROTARY_ENCODER_H

#include <stdint.h>
#include <stdbool.h>

// 旋转编码器事件类型
typedef enum
{
    ROTARY_EVENT_NONE = 0,
    ROTARY_EVENT_CLOCKWISE,          // 顺时针旋转
    ROTARY_EVENT_COUNTERCLOCKWISE,   // 逆时针旋转
    ROTARY_EVENT_BUTTON_PRESSED,     // 按钮按下
    ROTARY_EVENT_BUTTON_LONG_PRESSED // 按钮长按
} rotary_event_t;

// 旋转速度类型
typedef enum
{
    ROTARY_SPEED_STOP = 0,    // 停止
    ROTARY_SPEED_SLOW,        // 慢速
    ROTARY_SPEED_MEDIUM,      // 中速
    ROTARY_SPEED_FAST         // 快速
} rotary_speed_t;

// 函数声明
void rotary_encoder_init(void);
rotary_event_t rotary_encoder_process(void);
int16_t rotary_encoder_get_counter(void);
void rotary_encoder_reset_counter(void);
rotary_speed_t rotary_encoder_get_speed(void);

#endif // ROTARY_ENCODER_H
